var bProductWinAdd;
var bProductFormAdd;
function addBProduct(){
	initBProductFormAdd();
	bProductWinAdd = Ext.create('Ext.Window',{
		layout:'fit',
		width:800,
		height:400,
		maximized:true,
		maximizable:true,
		minimizable:true,
		animateTarget:document.body,
		plain:true,
		modal:true,
		title:'添加商品主数据',
		listeners:{
			minimize:function(win,opts){
				win.collapse();
			}
		},
		items:bProductFormAdd,
		buttons:[{
			text:'保存',
			itemId:'save',
			handler:function(button){
				Ext.getCmp('b_product_features').setValue(htmlEditor.html());
				submitForm(bProductFormAdd,'../bProductController/addBProduct',grid,bProductWinAdd,false,true);
			}
		},{
			text:'关闭',
			itemId:'close',
			handler:function(button){
				button.up('window').close();
			}
		}]
	});
	bProductWinAdd.show();
}
/**初始化添加**/
function initBProductFormAdd(){
	var addTab = Ext.create('Ext.TabPanel',{
		activeTab:0,
		region:'center',
		items:[
			{
			title:'基础信息',
			autoScroll:true,
			items:[{
						fieldLabel:'产品介绍',
						xtype:'textfield',
						hidden:true,
						id:'b_product_features',
						name:'b_product_features',
						anchor:'100%'
					},{
						fieldLabel:'产品名称',
						xtype:'textfield',
						name:'b_product_name',
						allowBlank:false,
						maxLength:200,
						width:350
					},
					{
						fieldLabel:'商品分类',
						xtype:'treepicker',
						displayField:'text',
						width:350,
						hiddenName:'b_category_id',
						name:'b_category_id',
						minPickerHeight:200,
						maxHeight:200,
						editable:false,
						rootVisible:false,
						allowBlank:false,
						emptyText:'请选择', 
						store:Ext.create('Ext.data.TreeStore',{
							fields:['id','text'],
							root:{
								text:'商品分类',
								id:'0',
								expanded:true
							},
							proxy:{
								type:'ajax',
								url:'../bCategoryController/getBCategoryListByCondition',
								reader:{
									type:'json'
								}
							}
						})
					},
					{
						fieldLabel:'商品品牌',
						xtype:"combo",
						store:b_brandList, 
						pageSize:10, 
			            emptyText:'请选择',  
			            mode:'local',  
			            triggerAction:'all',  
			            valueField:'b_brand_id',  
			            name:'b_brand_id',
			            displayField:'b_brand_name',  
			            editable:false, 
						allowBlank:false,
						maxLength:32,
						width:550
					},
					{
						fieldLabel:'条&nbsp;&nbsp;形&nbsp;码',
						xtype:'textfield',
						name:'b_product_barcode',
						maxLength:200,
						width:200
					},
					{
						fieldLabel:'商品货号',
						xtype:'textfield',
						name:'b_product_code',
						maxLength:32,
						width:200
					},
					{
						fieldLabel:'二&nbsp;&nbsp;维&nbsp;码',
						xtype:'textfield',
						name:'b_product_qr_code',
						maxLength:200,
						width:200
					},
					{
						fieldLabel:'状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态',
						xtype:"combo",
			            store:[["0","可用"],["1","禁用"]],
			            emptyText:"请选择",
			            mode:"local",
			            value:'0',
			            triggerAction:"all",
			            editable:false,
			            name:'b_product_status',
						hiddenName:'b_product_status',
						allowBlank:false,
						maxLength:2,
						width:200
					},
					{
						fieldLabel:'型&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号',
						xtype:'textfield',
						name:'b_product_model',
						maxLength:200,
						width:200
					},
					{
						fieldLabel:'型号名称',
						xtype:'textfield',
						name:'b_product_model_name',
						maxLength:200,
						width:200
					},
					{
						fieldLabel:'商品颜色',
						xtype:'textfield',
						name:'b_product_color',
						maxLength:30,
						width:200
					},
					{
						fieldLabel:'产&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地',
						xtype:'textareafield',
						name:'b_product_origin',
						maxLength:200,
						width:550
					},
					{
						fieldLabel:'质量等级',
						xtype:'textfield',
						name:'b_product_qualitylevel',
						maxLength:12,
						width:200
					},
					{
						fieldLabel:'商品毛重',
						xtype:'textfield',
						name:'b_product_gross_weight',
						width:200
					},
					{
						fieldLabel:'商品净重',
						xtype:'textfield',
						name:'b_product_net_weight',
						width:200
					},
					{
						fieldLabel:'尺寸长度',
						xtype:'numberfield',
						value:'0',
						name:'b_product_size_length',
						width:200
					},
					{
						fieldLabel:'尺寸宽度',
						xtype:'numberfield',
						value:'0',
						name:'b_product_size_width',
						width:200
					},
					{
						fieldLabel:'尺寸高度',
						xtype:'numberfield',
						value:'0',
						name:'b_product_size_height',
						width:200
					}
				  ]
		},
		{
			title:'商品介绍',
			layout:"fit",
		    items:[{
					name:'content',
					maxLength:65535,
		            border:true,
		            id:'content',
		            defaultValue:'',
		            listeners:{
					  "render":function(f){
		                   K = KindEditor;
		                   htmlEditor = K.create('#content', {                   	 
		                        uploadJson:'./kindeditor/upload_json.jsp',//路径自己改一下
		                        fileManagerJson:'./kindeditor/file_manager_json.jsp',//路径自己改一下
		                        height:300,
		                        width:'100%',
		                        resizeType:1,
								allowPreviewEmoticons:true,
								allowImageUpload:true
		                    });
		                }
					},
		            anchor:'100%'
				}]
		}
		/**
		{
			title:'商品介绍',
			layout:"fit",
		    items:[{
					name:'b_product_features',
					maxLength:65535,
					xtype:'htmleditor',
		            border:true,
		            id:'context',
		            defaultValue:'',
		            fontFamilies:['宋体','黑体','楷体'],
		            plugins:[
		                Ext.create('Ext.deng.form.HtmlEditorImage')
		            ],
		            anchor:'100%'
				}]
		}
		**/
		]
	});
	bProductFormAdd = Ext.create('Ext.FormPanel',{
		xtype:'form',
		waitMsgTarget:true,
		defaultType:'textfield',
		autoScroll:true,
		layout:"fit",
		fieldDefaults:{
			labelWidth:70,
			labelAlign:'left',
			flex:1,
			margin:'2 5 4 5'
		},
		items:[addTab]
	});
}